Skip to content

[ALT-11110] Detect local Python interpreters and apply the chosen one - #77

Open
Tsyklop wants to merge 3 commits into
mainfrom
bug/ALT-11110-python-interpreter
Open

Tsyklop wants to merge 3 commits into
mainfrom
bug/ALT-11110-python-interpreter

Conversation

@Tsyklop

@Tsyklop Tsyklop commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

ALT-11110. On PyCharm 2026.3.0.1 (macOS) the course wizard found no installed Python and only offered to download 3.14.7. If the user picked an installed interpreter with the browse button instead, the project opened with "No interpreter". The tester's log shows the cause of both.

Detection

WARN findSystemPythonPaths: SystemPythonService is not available
java.lang.NullPointerException: Cannot invoke "com.intellij.platform.eel.EelApi.getDescriptor()" because "eelApi" is null
	at ...SystemPythonServiceImpl.findSystemPythons(systemPythonServiceImpl.kt:146)
	at ...SystemPythonService.findSystemPythons$default(api.kt:35)
INFO findBaseSdks: SystemPythonService found 0 interpreters: []

The 263 shim calls SystemPythonService.findSystemPythons(eelApi, forceRefresh) through reflection, using the default-arguments bridge with null for eelApi. In 262 and the 263 EAP the bridge replaced it with localEel. In the 2026.3 release eelApi has no default, so null reached the service (checked with javap on PythonCore 262.9437.185 and 263.7307.200). The shim now calls the method directly and passes localEel.

Windows hid the bug: interpreters in the Python install manager directory (%LOCALAPPDATA%\Python) are still collected from disk there. macOS and Linux have no such fallback, so their list was empty.

Manually chosen interpreter

WARN SdkConfigurationUtil - Error creating or configuring sdk: ...; additionalData=[null]
java.lang.IllegalStateException: Sdk .../3.13/bin/python3 (2) ... doesn't have an additional data: it was created by buggy code.
WARN updateSdkIfNeeded: Failed to create new SDK

The chosen interpreter (PyDetectedSdk) was registered with SdkConfigurationUtil.createAndAddSDK, which creates the SDK without PythonSdkAdditionalData. Since 262 the Python plugin rejects such an SDK while setting it up, so the project SDK was set to null. The SDK is now created with additional data for the flavor the interpreter is detected as. If a registered SDK for the same interpreter already has additional data, it is reused instead of adding another python3 (2). This code is shared by all platforms, so the fix also applies to 262.

Build fixes

Two commits that are also on the ALT-11077 branch, which isn't merged yet. Without them main doesn't build against 263 locally:

  • Remove the dead maven.pkg.jetbrains.space repository (cherry-picked as is). It made the newly published PythonCore 263.7307.353 fail to resolve.
  • Declare intellij.platform.vcs.core and intellij.platform.builtInServer.impl for hs-core on 263. Otherwise hs-core:compileKotlin sometimes fails with unresolved VcsBundle and RestService.

Testing

Two new 263 tests:

  • PySystemPythonDiscoveryTest queries SystemPythonService.
  • PyManuallySelectedInterpreterTest runs a local interpreter through updateSdkIfNeeded and checks that the SDK has additional data.

With the old code each fails with the error from the tester's log (the NPE, and "buggy code" with no SDK). With the fix the 4 classes in newproject pass: 5 tests on 263, against PythonCore 263.7307.200 and 263.7307.353.

  • On Windows only. hs-Python also compiles on 252 and 262. I didn't run the full suite.
  • I haven't checked the wizard in PyCharm on macOS, so it still needs a manual pass of the scenario from the issue.

maven.pkg.jetbrains.space no longer resolves: JetBrains Space package
hosting is shut down. Gradle asks repositories in declaration order, and
this one came before the IntelliJ Platform and Marketplace repositories,
so every artifact that was not cached yet failed on it instead of falling
through to the next repository. The new Rust plugin build for 263
(263.7307.313) broke `:intellij-plugin:hs-Rust:compileKotlin` this way,
and any build against a new IDE version would too.

The only artifact taken from it, kotlin-css-jvm 2026.8.4, is on Maven
Central.
Since 2026.3 intellij.platform.vcs.core and
intellij.platform.builtInServer.impl are not on the core classpath.
hs-core got them only through the descriptor of intellij.platform.vcs.impl,
which the Gradle plugin sometimes generates without dependencies. Then
VcsBundle, VcsRevisionNumber and RestService don't resolve, and
hs-core:compileKotlin fails on 263.
On PyCharm 2026.3 the course wizard found no installed Python and only
offered to download 3.14.7, and an interpreter picked with the browse
button was not applied: the project opened with "No interpreter".

Detection: the 263 shim calls SystemPythonService.findSystemPythons
through reflection and relied on the default value of its eelApi
parameter (localEel). That default exists in 262 and the 263 EAP but was
removed in 2026.3, so null reached the service and it failed with an NPE.
localEel is now passed explicitly. Windows hid the bug, because
interpreters in the Python install manager directory are still collected
from disk there.

Manual choice: the chosen interpreter was registered with
SdkConfigurationUtil.createAndAddSDK, which creates an SDK without
PythonSdkAdditionalData. Since 262 the Python plugin rejects such an SDK
while setting it up ("it was created by buggy code"), so no SDK was set.
The SDK is now created with additional data for the detected flavor, and
an already registered SDK for the same interpreter is reused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant